import 'package:flutter/material.dart';
import 'package:hkzf/pages/home/tab_search/dataList.dart';
import 'package:hkzf/widgets/common_floatingactionbutton.dart';
import 'package:hkzf/widgets/room_list_item_widget.dart';

class RoomManage extends StatelessWidget {
  const RoomManage({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 2,
      initialIndex: 0,
      child: Scaffold(
        appBar: AppBar(
          title: Text('房屋管理'),
          bottom: TabBar(
            tabs: [
              Tab(text: '空置'),
              Tab(
                text: '已租',
              )
            ],
          ),
        ),
        body: TabBarView(
          children: [
            ListView(
                children: dataList
                    .map((item) => RoomListItemWidget(data: item))
                    .toList()),
            ListView(
                children: dataList
                    .map((item) => RoomListItemWidget(data: item))
                    .toList()),
          ],
        ),
        floatingActionButton: CommonFloatingActionButton('发布房源', () {
          Navigator.of(context).pushNamed('roomAdd');
        }),
        floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
      ),
    );
  }
}
